package com.itheima.springbootwebtlias.config;

import com.itheima.springbootwebtlias.interceptor.MyInterceptor;
import com.itheima.springbootwebtlias.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 1.springmvc配置类，配置拦截器，过滤器，全局异常处理等等
@Configuration // 标识当前类是配置类
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry
                .addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login"); //配置不拦截的多个路径
    }
}
